<?php
	class JsTagger extends jso{
			
		function ln($l){
			if(!isset($this->script)) $this->script = '';
			$this->script .= "$l\n";
		}
		
		function script(){
			return isset($this->script) ? $this->script : '';
		}
		
		function write_include($path){
			return array($path=>'<script type="text/javascript" src="'.$path.'" id="'.smuoi_clean_request_uri(basename($path)).'"></script>');
		}
		
		function include_before($element, $path){
			$this->insert_before($element, $this->write_include($path));
		}
		
		function append_include($path){
			$this->set($this->write_include($path));
		}		
		
		function write_string(){
			$js = '';
			$tag_open = false;
			foreach($this as $k=>$v){
				if($k == 'script'){
					$v = "<script type=\"text/javascript\">\n\t$v";	
					$tag_open = true;
				}elseif($tag_open){
					$v = "</script>\n$v";
					$tag_open = false;
				}
				$js .= "$v\n";
			}
			if($tag_open) $js .= "</script>\n";
			return trim($js);
		}
	}
	

